<?php
namespace app\index\controller;
use think\Cache;

class Index extends Common
{
    public function index()
    {


        //首页网络热播
        $infoIndexDy = curl_request(config('kanurl'). config('dy.index'));
        Cache::set('infoIndexDy', $infoIndexDy);
        $dy = getDyData(DeleteHtml(Cache::get('infoIndexDy')),'dy');
        $this->assign('dy_index_hot', DataNum($dy,'vname', 1, 6));
        //首页电视剧同步更新
        $infoIndexDsj = curl_request(config('kanurl'). config('dsj.index'));
        Cache::set('infoIndexDsj', $infoIndexDsj);
        $dsj= getDyData(DeleteHtml(Cache::get('infoIndexDsj')),'dsj');


        $this->assign('dsj_index_hot', DataNum($dsj,'vname', 1, 8));


        return view();
    }

    public function lst($types ='',$page = '1'){
        //列表页的 暂时在首页处理数据看看用
        if($page <= 1){
            $page = 1;
        }
        if($types == 'dy'){
            $durl =    config('dy.list');
        }
        if($types == 'dsj'){
            $durl =    config('dsj.list');
        }
        $url = config('kanurl') . $durl.'&pageno='.$page;
        $info = curl_request($url);
        Cache::set('info', $info);
        $data = getDyData(DeleteHtml(Cache::get('info')));
        $pages = array_reverse($data['page'][2]);
        $this->assign('data', $data);
        $this->assign('types', $types);
        $this->assign('pages', $pages);
        $this->assign('page', $page);
        return view();
    }
}
